package icu.mhb.mpj.example.vo;

import icu.mhb.mpj.example.entity.TestUserJson;
import icu.mhb.mpj.example.entity.Users;
import icu.mhb.mpj.example.entity.UsersAge;
import icu.mhb.mybatisplus.plugln.annotations.JoinField;
import icu.mhb.mybatisplus.plugln.annotations.conditions.*;
import icu.mhb.mybatisplus.plugln.annotations.order.AliasMapping;
import icu.mhb.mybatisplus.plugln.annotations.order.OrderBy;
import icu.mhb.mybatisplus.plugln.constant.RelevancyType;
import icu.mhb.mybatisplus.plugln.entity.JoinLambdaModel;
import lombok.Data;

import java.util.Date;
import java.util.List;

/**
 * @author mahuibo
 * @Title: UsersVo
 * @time 9/25/21 6:04 PM
 */
@Data
public class UsersVo {

    @Eq
    private Long id;

    @Le
    private Long userId;

    @In(mappingColum = "id")
    private Long ids;

    @Between(mappingColum = "id")
    private List<Long> ida;

    @OrderBy
    private String orderField;

//    @OrderBy
//    private List<String> orderField;
//    @OrderBy(aliasMapping = {
//            @AliasMapping(columnName = "id",filedName = "ageIds",tableAlias = "t2")
//    })
//    private String[] orderField;

    private String userName;

    private Date createTime;

    @Eq
    private Integer ageId;

    private Long ageTableId;

    private String mpnb;

    @NotLikeRight(tableAlias = "t2")
    private String ageDoc;

    @Le(tableAlias = "t2", mappingColum = "create_time")
    private String startTime;
    @Ge(tableAlias = "t2", mappingColum = "create_time", group = {Users.class})
    private String endTime;

    private String users_age_name;

    @JoinField(masterModelClass = Users.class, masterModelField = "ageId",
            sunModelClass = UsersAge.class, sunModelField = "id", relevancyType = RelevancyType.ONE_TO_ONE,
            sunAlias = "t1")
    private UsersAge usersAge;

    @JoinField(masterModelClass = Users.class, masterModelField = "ageId",
            sunModelClass = UsersAge.class, sunModelField = "id", relevancyType = RelevancyType.MANY_TO_MANY,
            sunAlias = "t2")
    private List<UsersAge> usersAges;

    private String ageName;

    private UsersAgeVo usersAgeVo;

    private TestUserJson contentJson;

    private TestUserJson contentJsonAge;

    private String ageIds;

    public static JoinLambdaModel<UsersAge, Users> toAge = JoinLambdaModel.of(UsersAge.class, UsersAge::getId, Users::getAgeId, "t2", (w) -> {
        w.eq(UsersAge::getId, 10086);
    });
}
